import { BehaviorNode } from "../BehaviorNode";
import { CompositeNode } from "../CompositeNode";
import { ATaskNode } from "../TaskNode";

 
 
/**
 * 简单平行节点,只有两个子节点
 */
export class BTSelector<T extends IGameEntity> extends CompositeNode<T>
{
    constructor(child:ATaskNode<T>,subTree:BehaviorNode<T>)
    {
        super();
        //this._children = [child,subTree]
    }
    protected getNextChildHandler(SearchData: IBehaviorTreeSearchData<T>, PrevChild: number, LastResult: BT_BEHAVIOR_CODE): number 
    {
        let NextChildIdx:number = BT_ReturnToParent;

        if (PrevChild == BT_NotInitialized)
        {
            // newly activated: start from first
            NextChildIdx = 0;
        }
        else if (LastResult == BT_FAILED && (PrevChild + 1) < this.getChildrenNum())
        {
            // failed = choose next child
            NextChildIdx = PrevChild + 1;
        }
    
        return NextChildIdx;
    }

 
   
}